package com.kamistoat.meimeimall.meimeimallcoupon.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.kamistoat.meimeimall.common.annotation.DubboAndHTTPExceptionCatch;
import com.kamistoat.meimeimall.common.annotation.LoginRequired;
import com.kamistoat.meimeimall.meimeimallcoupon.entity.CouponEntity;
import com.kamistoat.meimeimall.meimeimallcoupon.service.CouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import com.kamistoat.meimeimall.common.utils.R;


/**
 * 优惠券信息
 */
@Api(tags="优惠券数据库操作")
@RefreshScope
@RestController
@RequestMapping("coupon")
public class CouponController {
    @Autowired
    private CouponService couponService;

    /**
     * 仅仅用作测试nacos-config
     *
     * @return 配置中心的配置值
     */
    @Value("${coupon.user.name}")
    private String name;
    @Value("${coupon.user.age}")
    private Integer age;

    /**
     * 列表
     */
    @ApiOperation("从数据库获取列表")
    @GetMapping("/list")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R list(@RequestParam Map<String, Object> params) {
        return R.ok();
    }


    /**
     * 信息
     */
    @ApiOperation("从数据库查询指定的优惠券")
    @GetMapping("/coupon_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R info(@RequestParam("id") Long id) {
        return R.ok();
    }

    /**
     * 保存
     */
    @ApiOperation("向数据库保存优惠券")
    @PutMapping("/coupon_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R save(@RequestBody CouponEntity coupon) {
        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("向数据库更新优惠券")
    @PostMapping("/coupon_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R update(@RequestBody CouponEntity coupon) {
        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("从数据库删除指定优惠券")
    @DeleteMapping("/coupon_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R delete(@RequestBody Long[] ids) {
        return R.ok();
    }

}
